<template>
  <div class="jeecg-basic-table jeecg-basic-table-form-container">
    <!--查询区域-->
    <div class="">
      <a-form ref="formRef" class="jeecg-basic-table-form" @keyup.enter.native="reload" :model="queryParam"
        :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :gutter="24">
          <a-col :lg="6">
            <a-form-item label="报告编号" name="reportCode">
              <a-input placeholder="" v-model:value="queryParam.reportCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="6">
            <a-form-item label="委托单位" name="entName">
              <!-- <j-dict-select-tag placeholder="" v-model:value="queryParam.entName" :show-choose-option="false"
                dictCode="lab_enterprise,ent_name,ent_name" /> -->
                <j-input placeholder="" v-model:value="queryParam.entName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :lg="6">
            <a-form-item label="经办时间" name="handler">
              <a-date-picker valueFormat="YYYY-MM-DD" v-model:value="queryParam.handlDate"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <!-- <a-col :lg="6">
              <a-form-item label="经办人" name="handler">
                <a-input placeholder="" v-model:value="queryParam.handler"></a-input>
              </a-form-item>
            </a-col> -->
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-col :lg="6">
                <a-button type="primary" preIcon="ant-design:search-outlined" @click="reload">查询</a-button>
                <a-button preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
                <a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
                </a>
              </a-col>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!--引用表格-->
    <BasicTable @register="registerTable">
      <template #fileSlot="{ text }">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
        <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small"
          @click="downloadFile(text)">下载</a-button>
      </template>
    </BasicTable>
  </div>
</template>

<script lang="ts" name="entrust-labEntrust" setup>
import { ref, reactive } from 'vue';
import { BasicTable } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
// import { useModal } from '/@/components/Modal';
import { columns } from './LabEntrustCon.data';
import { list,getImportUrl, getExportUrl, } from './LabEntrustCon.api';
import { downloadFile } from '/@/utils/common/renderUtils';
// import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { JInput } from '/@/components/Form';


const formRef = ref();

const queryParam = reactive<any>({
  auditMark: '复审通过',
});
// 展开key
// const expandedRowKeys = ref<any[]>([]);

//注册table数据
const { tableContext} = useListPage({
  tableProps: {
    title: '合同归档',
    api: list,
    columns,
    canResize: false,
    useSearchForm: false,
    showIndexColumn: true,
    showActionColumn: false,
    size: 'small',
    tableSetting: {
      // 是否显示刷新按钮
      redo: false,
      // 是否显示尺寸调整按钮
      size: false,
      // 是否显示字段调整按钮
      setting: false,
      // 是否显示全屏按钮
      fullScreen: false,
    },
    beforeFetch: (params) => {
      return Object.assign(params, queryParam);
    },
  },
  exportConfig: {
    name: "委托信息表",
    url: getExportUrl,
    params: queryParam,
  },
  importConfig: {
    url: getImportUrl,
    success: handleSuccess
  },
})

const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext

/**
 * 成功回调
 */
function handleSuccess() {
  (selectedRowKeys.value = []) && reload();
}

/* ----------------------以下为原生查询需要添加的-------------------------- */
const toggleSearchStatus = ref<boolean>(false);
const labelCol = reactive({
  xs: { span: 24 },
  sm: { span: 7 },
});
const wrapperCol = reactive({
  xs: { span: 24 },
  sm: { span: 16 },
});
/**
 * 重置
 */
function searchReset() {
  formRef.value.resetFields();
  selectedRowKeys.value = [];
  //刷新数据
  reload();
}

</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
  .table-page-search-submitButtons {
    display: block;
    margin-bottom: 24px;
    white-space: nowrap;
  }

  .query-group-cust {
    width: calc(50% - 15px);
    min-width: 100px !important;
  }

  .query-group-split-cust {
    width: 30px;
    display: inline-block;
    text-align: center
  }
}

:deep(.ant-table-title) {
  display: none;
}

// .jeecg-basic-table-form {
//   height: 58px;
// }
</style>
